﻿using System.ServiceModel.Activation;
using Prompts.Service.ReportExecution;

namespace Prompts.Service.PromptService
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class ChildPromptLevelService : IChildPromptLevelService
    {
        private readonly IHierarchyPromptService _hierarchyPromptService;

        public ChildPromptLevelService(IHierarchyPromptService hierarchyPromptService)
        {
            _hierarchyPromptService = hierarchyPromptService;
        }

        public PromptLevel GetChildrenFor(string promptName, string parameterName, ParameterValue[] parameterValues)
        {
            var hierarhcy = _hierarchyPromptService.GetHierarchyPrompt(promptName, parameterValues);
            return hierarhcy.GetChildOf(parameterName);
        }

        //TODO this needs unit tests
        public PromptLevel GetChildrenFor2(string promptName, string parameterName, ParameterValue parameterValue)
        {
            var hierarhcy = _hierarchyPromptService.GetHierarchyPrompt(promptName,new[]{ parameterValue});
            return hierarhcy.GetChildOf(parameterName);
        }
    }
}
